home *** CD-ROM | disk | FTP | other *** search
- Path: ornews.intel.com!news
- From: thurman_b_miller@ccm2.hf.intel.com (Thurman Miller)
- Newsgroups: comp.lang.c++
- Subject: Syntax for looping through enumerated types
- Date: Mon, 08 Jan 1996 22:47:36 GMT
- Organization: Intel Corporation
- Message-ID: <4cs70o$8ns@ornews.intel.com>
- NNTP-Posting-Host: thurman-pc.ssd.intel.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- Suppose I have:
-
- enum daysoftheweek {MONDAY, TUESDAY, WEDNESDAY,THURSDAY,FRIDAY} ;
-
- How can I loop through this using a for statement?
-
- (the following doesn't work)
-
- daysoftheweek nIndex;
- for (nIndex=MONDAY;nIndex<=FRIDAY;nIndex++)
- {
-
- switch (nIndex):
- {
- case MONDAY:
- doMonday();
- }
-
- }
-
- I'd like to get away from specifying the beginning & end (ie MONDAY &
- TUESDAY) if possible because my enumerated list will constanty grow
- and I'd like to only change the definition of the enumerated list and
- the for statement would continue to work.
-
- Note: This is just a trivial example, not what I'm actually wanting to
- do.
-
- TIA
-
- Thurman Miller
-
-